Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NO MERGE] Report pressed keys #24986

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shoogle
Copy link
Contributor

@shoogle shoogle commented Oct 1, 2024

Following discussions in PR #24958, it would be useful to know how Qt is reporting keypresses on each platform. (Perhaps we should add a keylogger to the Diagnostic menu?)

For now, this PR just prints keys on the console. Download the artifact and run it on the command line to see how Qt reports keys on your system. On Windows it might be necessary to run it in Qt Creator or another debugger/IDE to see the console output.

Results with UK QWERTY PC keyboard on Windows

On this keyboard, + is entered with Shift =, thus combinations involving Shift = are conceptually using +.

On this platform, Qt's portable key names are equivalent to the native key names (at least in English).

Physical keys pressed Conceptual keys Qt portable/native keys Qt text
= = = =
Alt = Alt = Alt+= =
Ctrl = Ctrl = Ctrl+= =
Ctrl Alt = Ctrl Alt = ⚠️ Main window: Alt+=
Dialogs: Ctrl+Alt+=
=
Shift = + Shift++ +
Alt Shift = Alt + Alt+Shift++ +
Ctrl Shift = Ctrl + Ctrl+Shift++ ⚠️ =
Ctrl Alt Shift = Ctrl Alt + Ctrl+Alt+Shift++ ⚠️ =
Markdown
Physical keys pressed | Conceptual keys | Qt portable/native keys | Qt text
---:|---:|---:|---:
<kbd>Ctrl</kbd>&nbsp;<kbd>Alt</kbd>&nbsp;<kbd>=</kbd> | <kbd>Ctrl</kbd>&nbsp;<kbd>Alt</kbd>&nbsp;<kbd>=</kbd> | ⚠️ Main window: `Alt+=`<br>Dialogs: `Ctrl+Alt+=` | `=`

Reasonable people can disagree over whether it's better to show physical or conceptual keys in Preferences > Shortcuts. The real question is, which of those things (physical or conceptual) can we reliably determine based on the information Qt is reporting?

With this particular OS (Windows), keyboard layout (UK QWERTY PC), and key (=), it seems that dropping Shift from Qt's reported keys does give a reasonable approximation of the conceptual keys (but we know that's not the case for all keys).

There doesn't seem to be a straightforward way to determine the physical keys pressed. It might be possible using native methods as demonstrated here. However, the output of these methods is platform-specific.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant